package com.model.pool;

import com.face.ConstantDecorate;
import com.model.ClassInfo;
import com.model.structure.ConstantPool;
import com.util.Analysis;
import com.util.SystemNumber;
import lombok.Data;

/**
 *
 * @author seven
 */
@Data
public class ConstantMethodHandleInfo  extends BaseConstantDecorate implements ConstantDecorate {
    private Integer referenceKind;
    private Integer referenceKindLen=1;
    private Integer referenceIndex;
    private Integer referenceIndexLen=2;

    /**
     * 解析MethodHandle常量
     *
     * @param info
     */
    @Override public void invoke(ClassInfo info, Analysis analysis,int tag) {
        if (tag == SystemNumber.FIFTEEN) {
            this
                .setReferenceKind(analysis.util.sixteenToTenInt(analysis.readValue(this.getReferenceKindLen())));
            this
                .setReferenceIndex(analysis.util.sixteenToTenInt(analysis.readValue(this.getReferenceIndexLen())));
            this.setConstantPoolInfoType("CONSTANT_MethodHandle_info");
            this.setTag(tag);
            info.getPoolList().add(this);
        } else {
            new ConstantMethodInfo().invoke(info,analysis,tag);
        }
    }
}
